#include "studenti.h"

double Student::Average() const
{
    if (ArrayDb::size() > 0)
        return ArrayDb::sum() / ArrayDb::size();
    else
        return 0;
}
double & Student::operator[](int i)
{
    return ArrayDb::operator[](i);
}
double Student::operator[](int i) const
{
    return ArrayDb::operator[](i);
}
const std::string & Student::Name() const
{
    return (const std::string &) * this;
}

// friend
std::istream & operator>>(std::istream & is, Student & stu)
{
    is >> (std::string &) stu;
    return is;
}
std::istream & getline(std::istream & is, Student & stu)
{
    getline(is, (std::string &) stu);
    return is;
}
std::ostream & operator<<(std::ostream & os, const Student & stu)
{
    os << (std::string &) stu;
    stu.arr_out(os);
    return os;
}

std::ostream & Student::arr_out(std::ostream & os) const
{
    for (int i = 0; i < ArrayDb::size(); i++)
    {
        os << " " << ArrayDb::operator[](i);
    }
    os << std::endl;
    return os;
}
